﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function () {
        //var time = new Date();
        //var day = ('0' + time.getDate()).slice(-2);
        //var month = ('0' + (time.getMonth() + 1)).slice(-2);
        //var firstDay = time.getFullYear() + '-' + month + '-01';
        //var today = time.getFullYear() + '-' + month + '-' + day;
        //$('#startDate').val(firstDay);
        //$('#endDate').val(today);
        gridList();
        $("#gridList").jqGrid('setLabel', 'rn', '序号', { 'text-align': 'center', 'vertical-align': 'middle' });
    })
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/Gas/Resident/GetGridJson",
            height: $(window).height() - 96,
            @*postData: { 'StartDate': $("#startDate").val(), 'EndDate': $("#endDate").val() },*@
            colModel: [
                { label: "主键", name: "F_Id", hidden: true, key: true },
                { label: '姓名', name: 'RName', width: 50, align: 'left' },
                { label: '性别', name: 'Sex', width: 50, align: 'left' },
                { label: '身份证号', name: 'IDNumber', width: 150, align: 'left' },
                { label: '注册时间', name: 'FaceRecognizeTime', width: 150, align: 'left' },
                { label: '就餐次数', name: 'DiningRecordCount', width: 50, align: 'center' },
                { label: '社区名称', name: 'Address', width: 200, align: 'left' },
                { label: '联系方式', name: 'Telephone', width: 100, align: 'left' },
                @*{ label: '联系方式2', name: 'Telephone2', width: 100, align: 'left' },*@
                { label: '证件类型', name: 'CardType', width: 100, align: 'left' },
            ],
            pager: "#gridPager",
            sortname: 'FaceRecognizeTime desc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            var startDt = $("#startDate").val();
            var endDt = $("#endDate").val();
            $gridList.jqGrid('setGridParam', {
                @*postData: { RName: $("#txtRName").val(), IDNumber: $("#txtIDNumber").val(), StartDate: startDt, EndDate: endDt },*@
                postData: { RName: $("#txtRName").val(), IDNumber: $("#txtIDNumber").val()},
            }).trigger('reloadGrid');
        });
    }
    function btn_details() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        if (keyValue == null || keyValue == "") {
            alert("请选择想要查看的人员");
            return;
        }
        $.modalOpen({
            id: "Details",
            title: "查看居民",
            url: "/Gas/Resident/Details?keyValue=" + keyValue,
            width: "550px",
            height: "620px",
            btn: null,
        });
    }
    function btn_update() {
        var keyValue = $("#gridList").jqGridRowValue().F_Id;
        if (keyValue == null || keyValue == "") {
            alert("请选择想要更新的人员");
            return;
        }
        $.modalOpen({
            id: "Update",
            title: "信息修改",
            url: "/Gas/Resident/Update?keyValue=" + keyValue,
            width: "550px",
            height: "400px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();//提交表单
            }
        });
    }
    function btn_download() {
        window.location.href = "/Gas/Resident/Download_Excel";
    }
</script>

<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="btn_download()"><span class="glyphicon glyphicon-download"></span>&nbsp;模板下载</a>
        </div>
        <button class="btn btn-primary" data-toggle="modal" data-target="#my-modal" id="Import" href="/Gas/Resident/Upload">
            <i class="ace-icon glyphicon glyphicon-folder-close bigger-110 green"></i>导入
        </button>
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                <li><a id="NF-info" onclick="btn_details()"><i class="fa fa-info"></i>详情</a></li>
                <li><a id="NF-edit" onclick="btn_update()"><i class="fa fa-pencil-square-o"></i>修改</a></li>
            </ul>
            <a href="javascript:;" class="close"></a>
        </div>
        <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txtRName" type="text" class="form-control" placeholder="姓名" style="width: 200px;">&nbsp;&nbsp;&nbsp;&nbsp;
                        <input id="txtIDNumber" type="text" class="form-control" placeholder="身份证号" style="width: 200px;">
                        @*<input id="startDate" type="date" class="form-control" placeholder="开始日期" style="width: 200px;">*@
                        @*<input id="endDate" type="date" class="form-control" placeholder="结束日期" style="width: 200px;">*@
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
<div id="my-modal" class="modal fade" data-placement="center" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>